// @/api/group.js

import request from '@/utils/request'

// 获取分组树
export function getTree() {
  return request({
    url: '/api/groups/tree',
    method: 'get'
  })
}

// 创建分组
export function createGroup(data) {
  return request({
    url: '/api/groups',
    method: 'post',
    data
  })
}

// 更新分组
export function updateGroup(id, data) {
  return request({
    url: `/api/groups/${id}`,
    method: 'put',
    data
  })
}

// 删除分组
export function deleteGroup(id) {
  return request({
    url: `/api/groups/${id}`,
    method: 'delete'
  })
}

// 绑定用户到分组
export function bindUsers(groupId, userIds) {
  return request({
    url: `/api/groups/${groupId}/users/bind`,
    method: 'post',
    data: userIds
  })
}

// 从分组解绑用户
export function unbindUsers(groupId, userIds) {
  return request({
    url: `/api/groups/${groupId}/users/unbind`,
    method: 'post',
    data: userIds
  })
}

// 获取分组下的用户
export function getGroupUsers(groupId) {
  return request({
    url: `/api/groups/${groupId}/users`,
    method: 'get'
  })
}

export function getGroupTreeWithUsers() {
  return request({
    url: '/api/groups/tree-with-users',
    method: 'get'
  })
}

export function addPersonJob(data) {
  return request({
    url: '/api/example/WorkPersonJob/add',
    method: 'post',
    data
  })
}

export function addGroup(data) {
  return request({
    url: '/api/example/WorkPersonJob/addGroup',
    method: 'post',
    data
  })
}

export function getTaskListByUserId1() {
  return request({
    url: '/api/example/WorkPersonJob/getTaskListByUserId1',
    method: 'post'
  })
}


export function getTaskById(data) {
  return request({
    url: '/api/example/WorkPersonJob/page',
    method: 'post',
    data
  })
}

export function getTaskById1(data) {
  return request({
    url: '/api/example/WorkPersonJob/page-debug',
    method: 'post',
    data
  })
}

export function redisPush(data) {
  return request({
    url: '/api/example/test-publish',
    method: 'post',
    data
  })
}
